﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Twite
{
    public partial class Setting : Form

    {
        public string userId, password;
        public bool addStatus;
        public Font unreadFont,readFont;

        public Setting()
        {
            this.SettingLoad();

            InitializeComponent();
        }

        public void SettingLoad()
        {
            userId = Properties.Settings.Default.UserID;
            password = Properties.Settings.Default.Password;
            addStatus = Properties.Settings.Default.AddStatus;
            unreadFont = Properties.Settings.Default.UnreadFont;
            readFont = Properties.Settings.Default.ReadFont;
        }

        public void Save()
        {
            Properties.Settings.Default.UserID = userId;
            Properties.Settings.Default.Password = password;
            Properties.Settings.Default.AddStatus = addStatus;
            Properties.Settings.Default.UnreadFont = unreadFont;
            Properties.Settings.Default.ReadFont = readFont;

            Properties.Settings.Default.Save();
        }

        private void Setting_Load(object sender, EventArgs e)
        {
            userIdBox.Text = userId;
            passwordBox.Text = password;
            AddStatus.Checked = addStatus;

            unreadLabel.Font = unreadFont;
            unreadLabel.Text = unreadFont.ToString();
            readLabel.Font = readFont;
            readLabel.Text = readFont.ToString();

        }

        private void okButton_Click(object sender, EventArgs e)
        {
            applyButton_Click(sender, e);
            this.Close();
            return;
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void applyButton_Click(object sender, EventArgs e)
        {
            userId = userIdBox.Text;
            password = passwordBox.Text;
            addStatus = AddStatus.Checked;
            unreadFont = unreadLabel.Font;
            readFont = readLabel.Font;

            this.Save();
        }

        private void unreadButton_Click(object sender, EventArgs e)
        {
            fontDialog1.Font = unreadLabel.Font;
            fontDialog1.ShowDialog();
            unreadLabel.Font = fontDialog1.Font;
            unreadLabel.Text = unreadLabel.Font.ToString();
        }

        private void readButton_Click(object sender, EventArgs e)
        {
            fontDialog1.Font = readLabel.Font;
            fontDialog1.ShowDialog();
            readLabel.Font = fontDialog1.Font;
            readLabel.Text = readLabel.Font.ToString();
        }

    }
}
